<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<div>
		<p>
			文档分类
			<select name = "select">
				<option <c:if test="${empty edocCategory2 }">selected="selected" </c:if> value=-1>全部</option>
					<c:forEach items="${edocCategory }" var="obj">
						<option value="${obj.id }" <c:if test="${edocCategory2.id eq obj.id  }">selected="selected"</c:if> > ${obj.name }</option>
					</c:forEach>
			</select>
			<input name="selectBtn" type="button" value="查询" >&nbsp;&nbsp;&nbsp;&nbsp;
			<input name ="addBtn" type="button" value="新增电子文档" >
		</p>
		<input type="hidden" name="hidden" value="${edocCategory2 }">
		
		<table>
			<thead>
				<tr>
					<td colspan="6"><h1>电子文档列表</h1></td>
				</tr>
				<tr>
					<td>文档编号</td>
					<td>文档名称</td>
					<td>文档摘要</td>
					<td>上传人</td>
					<td>上传时间</td>
					<td>操作</td>
				</tr>
			</thead>
			<tbody>
				<c:forEach items="${edocEntries }" var="obj" varStatus="i">
					<tr>
						<td>${obj.id }</td>
						<td>${obj.title }</td>
						<td>${obj.summary }</td>
						<td>${obj.uploadUser }</td>
						<td><fmt:formatDate value="${obj.createDate }" pattern="yyyy-MM-dd"/></td>
						<td><a href="${ctx }/edocEntry/toUpdate/${obj.id}?pageNum=${pageInfo.pageNum}&selectVal=${select_val}">修改</a>&nbsp;&nbsp;<a href="${ctx }/edocEntry/deleteById/${obj.id}?pageNum=${pageInfo.pageNum}&selectVal=${select_val}&categoryId=${obj.categoryId}">删除</a></td>
						<%-- <td><a href="${ctx }/edocEntry/toUpdate/${obj.id}?categoryId=${obj.categoryId}&title = ${obj.title}">${obj.title}修改</a>&nbsp;&nbsp;<a href="">删除</a></td> --%>
					</tr>
				</c:forEach>
				<tr>
					<td colspan="6">
						<a href="javascript:void(0);" name="firstPage">首页</a>|
						<a href="javascript:void(0);" name="prePage">《上一页</a>
						<a href="javascript:void(0);" name="nextPage">下一页》</a>|
						<a href="javascript:void(0);" name="lastPage">尾页</a>
						<span>第${pageInfo.pageNum }页，共${pageInfo.pages }页</span>
					</td>
				</tr>
				<tr>
					<td colspan="6"><span name="span" style="display:block;color: red;text-align: center;"><c:if test="${not empty msg }">${msg }</c:if></span></td>
				</tr>
			</tbody>
		</table>
	</div>

	
	
	<form action="${ctx }/edocEntry/selectByInfo" method="post" >
		<input type="hidden" name="pageNum">
		<input type="hidden" name="categoryId">
		<input type="hidden" name="pageSize" value="3">
	</form>
	

</body>

<script type="text/javascript" src="${ctx }/static/js/jquery.js"></script>
<script type="text/javascript">
	
	$("input[name = selectBtn]").click(function () {
		var categoryId = $("select[name = select]").val();
			window.location = '${ctx}/edocEntry/selectByCategoryid?categoryId='+categoryId;
	});
	
	
	$("input[name = addBtn]").click(function () {
		var categoryId = $("select[name = select]").val();
			if(categoryId == -1){
				alert("请选择新增文档类别！");
			}else{
				window.location = '${ctx}/edocEntry/toAddDoc?categoryId='+categoryId;
			}
	});
	
	
	$("a[name = firstPage]").click(function(){
		var pageNum = 1;
		var categoryId = $("select[name = select]").val();
		$("input[name = pageNum]").val(pageNum);
		$("input[name = categoryId]").val(categoryId);
		$("form").submit();
	});
	
	$("a[name = prePage]").click(function(){
		var pageNum = ${pageInfo.pageNum -1};
		var categoryId = $("select[name = select]").val();
		$("input[name = pageNum]").val(pageNum);
		$("input[name = categoryId]").val(categoryId);
		if( pageNum < 1 ){
			alert("已是首页");
		}else{
			$("form").submit();
		}
		
	});
	
	$("a[name = nextPage]").click(function(){
		var pageNum = ${pageInfo.pageNum + 1};
		var categoryId = $("select[name = select]").val();
		var pages = ${pageInfo.pages }
		$("input[name = pageNum]").val(pageNum);
		$("input[name = categoryId]").val(categoryId);
		if( pageNum > pages ){
			alert("已是尾页");
		}else{
			$("form").submit();
		}
	});
	
	
	$("a[name = lastPage]").click(function(){
		var pageNum = ${pageInfo.pages }
		var categoryId = $("select[name = select]").val();
		$("input[name = pageNum]").val(pageNum);
		$("input[name = categoryId]").val(categoryId);
		$("form").submit();
	});

	

</script>
</html>